local skynet = require "skynet"
local httpc = require "http.httpc"
local md5 = require "md5"
local cjson = require "cjson"

function func1()
	print("GET api.weibo.com")
	local header = {
		access_token = DKJ,
	}
	local status, body = httpc.get("api.weibo.com", "/oauth2/get_token_info", header)
	print("[header] =====>")
	for k,v in pairs(header) do
		print(k,v)
	end
	print("[body] =====>", status)
	print(body)
end

skynet.start(function()
	local data = {sid = "ssh1gameda0c58c5a4714bdc82fe35a7d9d46f4c190792"}
	-- sign
	local dataKList = {}
	local sign = ""
	for k,v in pairs(data) do
		dataKList[#dataKList+1] = k
	end
	table.sort( dataKList )
	for _,k in ipairs(dataKList) do
		sign = string.format("%s%s=%s",sign,tostring(k),tostring(data[k]))
	end
	sign = string.format("%s%s",sign,"4e1c27908606818f73df9620b7a7785c")
	sign = md5.sumhexa(sign)
	--
	local context = {
		id = os.time(),
		data = data,
		game = {gameId = 552521},
		sign = sign,
		service = "account.verifySession",
	}
	local status, body = httpc.get(
								"sdk.g.uc.cn",
								"/cp/account.verifySession", 
								{},
								{},
								cjson.encode(context)
							)
	print(body)
	skynet.exit()
end)
